<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Tacopie: includes/tacopie/network/tcp_client.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="tacopie_logo.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Tacopie
   &#160;<span id="projectnumber">3.0.0</span>
   </div>
   <div id="projectbrief">Tacopie is a TCP Client &amp; Server C++11 library.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_09e761304027c904456130627fd4dcf5.html">includes</a></li><li class="navelem"><a class="el" href="dir_9a013686e2522dd95763481288c1f90f.html">tacopie</a></li><li class="navelem"><a class="el" href="dir_1619eefbac1db14eaf18adaf83ce3ccc.html">network</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">tcp_client.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">// MIT License</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">// Copyright (c) 2016-2017 Simon Ninon &lt;simon.ninon@gmail.com&gt;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">// Permission is hereby granted, free of charge, to any person obtaining a copy</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">// of this software and associated documentation files (the &quot;Software&quot;), to deal</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">// in the Software without restriction, including without limitation the rights</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment">// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">// copies of the Software, and to permit persons to whom the Software is</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">// furnished to do so, subject to the following conditions:</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">// The above copyright notice and this permission notice shall be included in all</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">// copies or substantial portions of the Software.</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">// THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment">// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment">// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment">// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment">// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">// SOFTWARE.</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &lt;atomic&gt;</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &lt;cstdint&gt;</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &lt;mutex&gt;</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &lt;queue&gt;</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &lt;tacopie/network/io_service.hpp&gt;</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &lt;tacopie/network/tcp_socket.hpp&gt;</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &lt;tacopie/utils/typedefs.hpp&gt;</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacetacopie.html">tacopie</a> {</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="classtacopie_1_1tcp__client.html">   41</a></span>&#160;<span class="keyword">class </span><a class="code" href="classtacopie_1_1tcp__client.html">tcp_client</a> {</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  <a class="code" href="classtacopie_1_1tcp__client.html#a9293d5ef2b804f17d778504165ba0c52">tcp_client</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  ~<a class="code" href="classtacopie_1_1tcp__client.html">tcp_client</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  <span class="keyword">explicit</span> <a class="code" href="classtacopie_1_1tcp__client.html#a9293d5ef2b804f17d778504165ba0c52">tcp_client</a>(<a class="code" href="classtacopie_1_1tcp__socket.html">tcp_socket</a>&amp;&amp; socket);</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  <a class="code" href="classtacopie_1_1tcp__client.html#a9293d5ef2b804f17d778504165ba0c52">tcp_client</a>(<span class="keyword">const</span> <a class="code" href="classtacopie_1_1tcp__client.html">tcp_client</a>&amp;) = <span class="keyword">delete</span>;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;  <a class="code" href="classtacopie_1_1tcp__client.html">tcp_client</a>&amp; <a class="code" href="classtacopie_1_1tcp__client.html#aeadcfb8cd727b2917ebcd357311d0a6b">operator=</a>(<span class="keyword">const</span> <a class="code" href="classtacopie_1_1tcp__client.html">tcp_client</a>&amp;) = <span class="keyword">delete</span>;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classtacopie_1_1tcp__client.html#af7a1796c04efd00542349ecab692e073">operator==</a>(<span class="keyword">const</span> <a class="code" href="classtacopie_1_1tcp__client.html">tcp_client</a>&amp; rhs) <span class="keyword">const</span>;</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classtacopie_1_1tcp__client.html#af352b6b1e939c919aec2761517051eb9">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classtacopie_1_1tcp__client.html">tcp_client</a>&amp; rhs) <span class="keyword">const</span>;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keyword">const</span> std::string&amp; <a class="code" href="classtacopie_1_1tcp__client.html#ad38ab710c5eca64de2f887abc455b15d">get_host</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  std::uint32_t <a class="code" href="classtacopie_1_1tcp__client.html#a3b42ae2afe6d5ee5f2f16b8bd7846f37">get_port</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classtacopie_1_1tcp__client.html#a0cfbb18cb72aa3b6a41921f61cacc425">connect</a>(<span class="keyword">const</span> std::string&amp; host, std::uint32_t port, std::uint32_t timeout_msecs = 0);</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classtacopie_1_1tcp__client.html#a7562e0bfa24912595d6f695f848b9e51">disconnect</a>(<span class="keywordtype">bool</span> wait_for_removal = <span class="keyword">false</span>);</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classtacopie_1_1tcp__client.html#a9bf568812c8350260843842e7952c8c3">is_connected</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  <span class="keywordtype">void</span> call_disconnection_handler(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00120"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1read__result.html">  120</a></span>&#160;  <span class="keyword">struct </span><a class="code" href="structtacopie_1_1tcp__client_1_1read__result.html">read_result</a> {</div><div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1read__result.html#a9bb917b8d210159a95655a6f8da8e96e">  124</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="structtacopie_1_1tcp__client_1_1read__result.html#a9bb917b8d210159a95655a6f8da8e96e">success</a>;</div><div class="line"><a name="l00128"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1read__result.html#a50d22ea3a43d085d88d54bbf59a357dc">  128</a></span>&#160;    std::vector&lt;char&gt; <a class="code" href="structtacopie_1_1tcp__client_1_1read__result.html#a50d22ea3a43d085d88d54bbf59a357dc">buffer</a>;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;  };</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;</div><div class="line"><a name="l00136"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1write__result.html">  136</a></span>&#160;  <span class="keyword">struct </span><a class="code" href="structtacopie_1_1tcp__client_1_1write__result.html">write_result</a> {</div><div class="line"><a name="l00140"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1write__result.html#a4a8d5706c83068a97c10e63c6080e6a3">  140</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="structtacopie_1_1tcp__client_1_1write__result.html#a4a8d5706c83068a97c10e63c6080e6a3">success</a>;</div><div class="line"><a name="l00144"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1write__result.html#acee9eca954a6f1b6283c6188eead2ab1">  144</a></span>&#160;    std::size_t <a class="code" href="structtacopie_1_1tcp__client_1_1write__result.html#acee9eca954a6f1b6283c6188eead2ab1">size</a>;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;  };</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00152"></a><span class="lineno"><a class="line" href="classtacopie_1_1tcp__client.html#acdf9dea8bac6c56f7b04ce38b9432322">  152</a></span>&#160;  <span class="keyword">typedef</span> std::function&lt;void(read_result&amp;)&gt; <a class="code" href="classtacopie_1_1tcp__client.html#acdf9dea8bac6c56f7b04ce38b9432322">async_read_callback_t</a>;</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;</div><div class="line"><a name="l00158"></a><span class="lineno"><a class="line" href="classtacopie_1_1tcp__client.html#ad48b8c8dff8a77490eb2e3e802c82b97">  158</a></span>&#160;  <span class="keyword">typedef</span> std::function&lt;void(write_result&amp;)&gt; <a class="code" href="classtacopie_1_1tcp__client.html#ad48b8c8dff8a77490eb2e3e802c82b97">async_write_callback_t</a>;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00166"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1read__request.html">  166</a></span>&#160;  <span class="keyword">struct </span><a class="code" href="structtacopie_1_1tcp__client_1_1read__request.html">read_request</a> {</div><div class="line"><a name="l00170"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1read__request.html#ad8b69f61884c60596aface363ca947a3">  170</a></span>&#160;    std::size_t <a class="code" href="structtacopie_1_1tcp__client_1_1read__request.html#ad8b69f61884c60596aface363ca947a3">size</a>;</div><div class="line"><a name="l00174"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1read__request.html#a3d495e82e38efebf763f595392b0db46">  174</a></span>&#160;    async_read_callback_t <a class="code" href="structtacopie_1_1tcp__client_1_1read__request.html#a3d495e82e38efebf763f595392b0db46">async_read_callback</a>;</div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;  };</div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;</div><div class="line"><a name="l00182"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1write__request.html">  182</a></span>&#160;  <span class="keyword">struct </span><a class="code" href="structtacopie_1_1tcp__client_1_1write__request.html">write_request</a> {</div><div class="line"><a name="l00186"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1write__request.html#a4ee0c159b630c14f81d6b6d7d4b4e826">  186</a></span>&#160;    std::vector&lt;char&gt; <a class="code" href="structtacopie_1_1tcp__client_1_1write__request.html#a4ee0c159b630c14f81d6b6d7d4b4e826">buffer</a>;</div><div class="line"><a name="l00190"></a><span class="lineno"><a class="line" href="structtacopie_1_1tcp__client_1_1write__request.html#a04fd3e5484ba322d0112024bf8823623">  190</a></span>&#160;    async_write_callback_t <a class="code" href="structtacopie_1_1tcp__client_1_1write__request.html#a04fd3e5484ba322d0112024bf8823623">async_write_callback</a>;</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  };</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classtacopie_1_1tcp__client.html#a120e3ec2902acc902f7a0b27074bda6b">async_read</a>(<span class="keyword">const</span> <a class="code" href="structtacopie_1_1tcp__client_1_1read__request.html">read_request</a>&amp; request);</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;</div><div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classtacopie_1_1tcp__client.html#a2304ed6d4ca0cbc74e6aa72d3e92b76a">async_write</a>(<span class="keyword">const</span> <a class="code" href="structtacopie_1_1tcp__client_1_1write__request.html">write_request</a>&amp; request);</div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;  <a class="code" href="classtacopie_1_1tcp__socket.html">tacopie::tcp_socket</a>&amp; <a class="code" href="classtacopie_1_1tcp__client.html#a1a3834deb1d263ec5816066f74286298">get_socket</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;  <span class="keyword">const</span> <a class="code" href="classtacopie_1_1tcp__socket.html">tacopie::tcp_socket</a>&amp; <a class="code" href="classtacopie_1_1tcp__client.html#a1a3834deb1d263ec5816066f74286298">get_socket</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;</div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;</div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;  <span class="keyword">const</span> std::shared_ptr&lt;tacopie::io_service&gt;&amp; <a class="code" href="classtacopie_1_1tcp__client.html#aafbf0aa37cd0472778d09fb163362314">get_io_service</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;</div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00231"></a><span class="lineno"><a class="line" href="classtacopie_1_1tcp__client.html#aca5df52e5ee6fa673cf212532ada1453">  231</a></span>&#160;  <span class="keyword">typedef</span> std::function&lt;void()&gt; <a class="code" href="classtacopie_1_1tcp__client.html#aca5df52e5ee6fa673cf212532ada1453">disconnection_handler_t</a>;</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;</div><div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classtacopie_1_1tcp__client.html#a8c290d681186edb0578051c04f3c0762">set_on_disconnection_handler</a>(<span class="keyword">const</span> disconnection_handler_t&amp; disconnection_handler);</div><div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;</div><div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;  <span class="keywordtype">void</span> on_read_available(fd_t fd);</div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;  <span class="keywordtype">void</span> on_write_available(fd_t fd);</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;</div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;  <span class="keywordtype">void</span> clear_read_requests(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;</div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;  <span class="keywordtype">void</span> clear_write_requests(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;  async_read_callback_t process_read(<a class="code" href="structtacopie_1_1tcp__client_1_1read__result.html">read_result</a>&amp; result);</div><div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;</div><div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;  async_write_callback_t process_write(<a class="code" href="structtacopie_1_1tcp__client_1_1write__result.html">write_result</a>&amp; result);</div><div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;</div><div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;  std::shared_ptr&lt;io_service&gt; m_io_service;</div><div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;</div><div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;  <a class="code" href="classtacopie_1_1tcp__socket.html">tacopie::tcp_socket</a> m_socket;</div><div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;</div><div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;  std::atomic&lt;bool&gt; m_is_connected = ATOMIC_VAR_INIT(<span class="keyword">false</span>);</div><div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;</div><div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;  std::queue&lt;read_request&gt; m_read_requests;</div><div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;  std::queue&lt;write_request&gt; m_write_requests;</div><div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;</div><div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;  std::mutex m_read_requests_mtx;</div><div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;  std::mutex m_write_requests_mtx;</div><div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;</div><div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;  disconnection_handler_t m_disconnection_handler;</div><div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;};</div><div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;</div><div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;} <span class="comment">// namespace tacopie</span></div><div class="ttc" id="classtacopie_1_1tcp__client_html_a0cfbb18cb72aa3b6a41921f61cacc425"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a0cfbb18cb72aa3b6a41921f61cacc425">tacopie::tcp_client::connect</a></div><div class="ttdeci">void connect(const std::string &amp;host, std::uint32_t port, std::uint32_t timeout_msecs=0)</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1read__result_html_a9bb917b8d210159a95655a6f8da8e96e"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1read__result.html#a9bb917b8d210159a95655a6f8da8e96e">tacopie::tcp_client::read_result::success</a></div><div class="ttdeci">bool success</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:124</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_ad48b8c8dff8a77490eb2e3e802c82b97"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#ad48b8c8dff8a77490eb2e3e802c82b97">tacopie::tcp_client::async_write_callback_t</a></div><div class="ttdeci">std::function&lt; void(write_result &amp;)&gt; async_write_callback_t</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:158</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a7562e0bfa24912595d6f695f848b9e51"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a7562e0bfa24912595d6f695f848b9e51">tacopie::tcp_client::disconnect</a></div><div class="ttdeci">void disconnect(bool wait_for_removal=false)</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a120e3ec2902acc902f7a0b27074bda6b"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a120e3ec2902acc902f7a0b27074bda6b">tacopie::tcp_client::async_read</a></div><div class="ttdeci">void async_read(const read_request &amp;request)</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1read__request_html_ad8b69f61884c60596aface363ca947a3"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1read__request.html#ad8b69f61884c60596aface363ca947a3">tacopie::tcp_client::read_request::size</a></div><div class="ttdeci">std::size_t size</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:170</div></div>
<div class="ttc" id="classtacopie_1_1tcp__socket_html"><div class="ttname"><a href="classtacopie_1_1tcp__socket.html">tacopie::tcp_socket</a></div><div class="ttdef"><b>Definition:</b> tcp_socket.hpp:38</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a9bf568812c8350260843842e7952c8c3"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a9bf568812c8350260843842e7952c8c3">tacopie::tcp_client::is_connected</a></div><div class="ttdeci">bool is_connected(void) const</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_aafbf0aa37cd0472778d09fb163362314"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#aafbf0aa37cd0472778d09fb163362314">tacopie::tcp_client::get_io_service</a></div><div class="ttdeci">const std::shared_ptr&lt; tacopie::io_service &gt; &amp; get_io_service(void) const</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a8c290d681186edb0578051c04f3c0762"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a8c290d681186edb0578051c04f3c0762">tacopie::tcp_client::set_on_disconnection_handler</a></div><div class="ttdeci">void set_on_disconnection_handler(const disconnection_handler_t &amp;disconnection_handler)</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1read__result_html"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1read__result.html">tacopie::tcp_client::read_result</a></div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:120</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a3b42ae2afe6d5ee5f2f16b8bd7846f37"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a3b42ae2afe6d5ee5f2f16b8bd7846f37">tacopie::tcp_client::get_port</a></div><div class="ttdeci">std::uint32_t get_port(void) const</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1write__result_html"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1write__result.html">tacopie::tcp_client::write_result</a></div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:136</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_af7a1796c04efd00542349ecab692e073"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#af7a1796c04efd00542349ecab692e073">tacopie::tcp_client::operator==</a></div><div class="ttdeci">bool operator==(const tcp_client &amp;rhs) const</div></div>
<div class="ttc" id="namespacetacopie_html"><div class="ttname"><a href="namespacetacopie.html">tacopie</a></div><div class="ttdef"><b>Definition:</b> io_service.hpp:48</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_af352b6b1e939c919aec2761517051eb9"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#af352b6b1e939c919aec2761517051eb9">tacopie::tcp_client::operator!=</a></div><div class="ttdeci">bool operator!=(const tcp_client &amp;rhs) const</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1write__result_html_a4a8d5706c83068a97c10e63c6080e6a3"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1write__result.html#a4a8d5706c83068a97c10e63c6080e6a3">tacopie::tcp_client::write_result::success</a></div><div class="ttdeci">bool success</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:140</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1write__request_html_a4ee0c159b630c14f81d6b6d7d4b4e826"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1write__request.html#a4ee0c159b630c14f81d6b6d7d4b4e826">tacopie::tcp_client::write_request::buffer</a></div><div class="ttdeci">std::vector&lt; char &gt; buffer</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:186</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_aca5df52e5ee6fa673cf212532ada1453"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#aca5df52e5ee6fa673cf212532ada1453">tacopie::tcp_client::disconnection_handler_t</a></div><div class="ttdeci">std::function&lt; void()&gt; disconnection_handler_t</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:231</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_acdf9dea8bac6c56f7b04ce38b9432322"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#acdf9dea8bac6c56f7b04ce38b9432322">tacopie::tcp_client::async_read_callback_t</a></div><div class="ttdeci">std::function&lt; void(read_result &amp;)&gt; async_read_callback_t</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:152</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1read__request_html"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1read__request.html">tacopie::tcp_client::read_request</a></div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:166</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html"><div class="ttname"><a href="classtacopie_1_1tcp__client.html">tacopie::tcp_client</a></div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:41</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1read__request_html_a3d495e82e38efebf763f595392b0db46"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1read__request.html#a3d495e82e38efebf763f595392b0db46">tacopie::tcp_client::read_request::async_read_callback</a></div><div class="ttdeci">async_read_callback_t async_read_callback</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:174</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a1a3834deb1d263ec5816066f74286298"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a1a3834deb1d263ec5816066f74286298">tacopie::tcp_client::get_socket</a></div><div class="ttdeci">tacopie::tcp_socket &amp; get_socket(void)</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1read__result_html_a50d22ea3a43d085d88d54bbf59a357dc"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1read__result.html#a50d22ea3a43d085d88d54bbf59a357dc">tacopie::tcp_client::read_result::buffer</a></div><div class="ttdeci">std::vector&lt; char &gt; buffer</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:128</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a2304ed6d4ca0cbc74e6aa72d3e92b76a"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a2304ed6d4ca0cbc74e6aa72d3e92b76a">tacopie::tcp_client::async_write</a></div><div class="ttdeci">void async_write(const write_request &amp;request)</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_a9293d5ef2b804f17d778504165ba0c52"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#a9293d5ef2b804f17d778504165ba0c52">tacopie::tcp_client::tcp_client</a></div><div class="ttdeci">tcp_client(void)</div><div class="ttdoc">ctor &amp; dtor </div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_ad38ab710c5eca64de2f887abc455b15d"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#ad38ab710c5eca64de2f887abc455b15d">tacopie::tcp_client::get_host</a></div><div class="ttdeci">const std::string &amp; get_host(void) const</div></div>
<div class="ttc" id="classtacopie_1_1tcp__client_html_aeadcfb8cd727b2917ebcd357311d0a6b"><div class="ttname"><a href="classtacopie_1_1tcp__client.html#aeadcfb8cd727b2917ebcd357311d0a6b">tacopie::tcp_client::operator=</a></div><div class="ttdeci">tcp_client &amp; operator=(const tcp_client &amp;)=delete</div><div class="ttdoc">assignment operator </div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1write__result_html_acee9eca954a6f1b6283c6188eead2ab1"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1write__result.html#acee9eca954a6f1b6283c6188eead2ab1">tacopie::tcp_client::write_result::size</a></div><div class="ttdeci">std::size_t size</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:144</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1write__request_html"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1write__request.html">tacopie::tcp_client::write_request</a></div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:182</div></div>
<div class="ttc" id="structtacopie_1_1tcp__client_1_1write__request_html_a04fd3e5484ba322d0112024bf8823623"><div class="ttname"><a href="structtacopie_1_1tcp__client_1_1write__request.html#a04fd3e5484ba322d0112024bf8823623">tacopie::tcp_client::write_request::async_write_callback</a></div><div class="ttdeci">async_write_callback_t async_write_callback</div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:190</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
